package com.wyw.design.model.learning.behavioral.memo;

/**
 * @Title   Originator
 * @Description
 * @Author Mr Wu yewen.wu.china@gmail.com
 * @Date 2023/4/20 11:14
 * Update History:
 * Author        Time            Content
 */
public class BankAccount {
    private int balance;

    public BankAccount(int balance) {
        this.balance = balance;
    }

    public int getBalance() {
        return balance;
    }

    public void deposit(int amount) {
        balance += amount;
    }

    public void withdraw(int amount) {
        balance -= amount;
    }

    public Memento save() {
        return new Memento(balance);
    }

    public void restore(Memento memento) {
        balance = memento.getBalance();
    }
}
